<template>
	<view class="main">
		<guide v-if="guidePages" :advData="advData"></guide>
	</view>
</template>

<script>
	import guide from '@/components/guide/index.vue'
	import Cache from '@/utils/cache';
	import {
		getGuide
	} from '@/api/api.js';
	export default {
		components: {
			guide
		},
		data() {
			return {
				guidePages: false,
				advData: ''
			}
		},
		onShow() {
			// #ifdef H5
			if(this.$wechat.isWeixin()){
				this.$wechat.wechat();
			}
			// #endif
			this.loadExecution()
		},
		methods: {
			loadExecution() {
				// const tagDate = uni.getStorageSync('guideDate') || '',
				// 	nowDate = new Date().toLocaleDateString();
				// if (tagDate === nowDate) {
				// 	uni.switchTab({
				// 		url: '/pages/index/index'
				// 	});
				// 	return
				// }
				getGuide().then(res => {
					if (res.data.isShow == "1") {
						this.advData = res.data
						uni.setStorageSync('guideDate', new Date().toLocaleDateString());
						this.guidePages = true
					} else {
						uni.switchTab({
							url: '/pages/index/index'
						});
					}
				}).catch(err => {
					uni.switchTab({
						url: '/pages/index/index'
					});
				})
			}
		},
		onHide() {
			this.guidePages = false
		}
	}
</script>

<style>
	page,
	.main {
		width: 100%;
		height: 100%;
	}
</style>
